#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import datetime
import socket
import time
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor


def tesk(num):
    # print("start...")
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.settimeout(1)
    x = server.connect_ex(("127.0.0.1", num))
    if x == 0:
        print("连接正常 {}".format(num))


def result():
    pass


if __name__ == '__main__':
    print(datetime.datetime.now())
    p = ThreadPoolExecutor(8)
    port_list = [80, 99, 7003, 5040, 8680]
    for i in port_list:
        p.submit(tesk, i)
    p.shutdown()

    print("main")
    print(datetime.datetime.now())
